Attribute VB_Name = "RegExpExecute"
Option Explicit

Function RegExpExecute(iput As Variant, sRule As String)
    '字符串提取
    Dim mj As String, m As Object
    Dim i%
    Dim reg As Object
    Set reg = CreateObject("vbscript.regexp")
    With reg
        .Pattern = sRule '规则
        .Global = True '多次匹配还是一次
        .IgnoreCase = True '是否区分大小写
        .MultiLine = True  '搜索字符串是否分布在多行
    End With
    
    '输出=reg.Execute(输入)
    '正则拆出来的东西是集合，而不是字符串，所以不能Value或Range输出
    Set m = reg.Execute(iput)
    
    
    For i = 0 To m.Count - 1
        mj = mj & m.Item(i).Value
    Next i
    
    RegExpExecute = mj
End Function
